package com.example.hls_homework3;

import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class SystemInfoActivity extends AppCompatActivity {

    TextView tvShowOri, tvShowNav, tvShowMnc, tvShowTouch;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_system_info);

        tvShowOri = findViewById(R.id.tv_system_info_activity_ori);
        tvShowNav = findViewById(R.id.tv_system_info_activity_nav);
        tvShowTouch = findViewById(R.id.tv_system_info_activity_touch);
        tvShowMnc = findViewById(R.id.tv_system_info_activity_mnc);

        Configuration cfg = getResources().getConfiguration();

        // 屏幕方向
        String screen = cfg.orientation == Configuration.ORIENTATION_LANDSCAPE ?
                "横向屏幕" : "竖向屏幕";

        // 移动网络代码
        String mncCode = cfg.mnc + "";

        // 导航方式
        String naviName;
        switch (cfg.navigation) {
            case Configuration.NAVIGATION_NONAV:
                naviName = "没有方向控制";
                break;
            case Configuration.NAVIGATION_WHEEL:
                naviName = "滚轮控制方向";
                break;
            case Configuration.NAVIGATION_DPAD:
                naviName = "方向键控制方向";
                break;
            case Configuration.NAVIGATION_TRACKBALL:
                naviName = "轨迹球控制方向";
                break;
            default:
                naviName = "未知导航方式";
        }

        // 触摸屏类型
        String touchName;
        switch (cfg.touchscreen) {
            case Configuration.TOUCHSCREEN_NOTOUCH:
                touchName = "无触摸屏";
                break;
            case Configuration.TOUCHSCREEN_STYLUS:
                touchName = "触摸笔式触摸屏";
                break;
            case Configuration.TOUCHSCREEN_FINGER:
                touchName = "接受手指的触摸屏";
                break;
            default:
                touchName = "未知触摸屏类型";
        }

        tvShowOri.setText(screen);
        tvShowNav.setText(naviName);
        tvShowMnc.setText("MNC代码: " + mncCode);
        tvShowTouch.setText(touchName);
    }
}